package com.activiti.Test;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ManagementService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.identity.Group;
import org.activiti.engine.impl.RepositoryServiceImpl;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.DelegationState;
import org.activiti.engine.task.Task;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Deploy {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext("com/activiti/config/applicationContext-data.xml");
		RepositoryService repositoryService=(RepositoryService)applicationContext.getBean("repositoryService");
//		repositoryService.createDeployment().addClasspathResource("com/activiti/liucheng/baoxiao.bpmn20.xml").name("报销").deploy();
		RuntimeService runtimeService=(RuntimeService)applicationContext.getBean("runtimeService");
		TaskService taskService=(TaskService)applicationContext.getBean("taskService");
		HistoryService historyService=(HistoryService)applicationContext.getBean("historyService");
//		ProcessInstance processInstance=runtimeService.startProcessInstanceByKey("Baoxiao");
//		System.out.println(processInstance.getId());
			
		
		List<Task> tasks=new ArrayList<Task>();
		tasks.add(taskService.createTaskQuery().taskId("9316").singleResult());
		System.out.println(tasks.get(0).getId());
//		List<Task> tasks=taskService.createTaskQuery().taskAssignee("jay").list();
//		List<String>tList=new ArrayList<String>();
//		System.out.println(tasks.size());
//		for(Task task:tasks){
//			tList.add(task.getId());
//		}
//		taskService.deleteTasks(tList, true);
	}
}
